import React from "react";
import { HashRouter, Switch, Route, Redirect } from "react-router-dom";
import Cookie from "react-cookies";
import Login from "../views/login";
import Layout from "../views/layout";

class index extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  render() {
    return (
      <HashRouter>
        <Switch>
          <Route exact path="/login" component={Login}></Route>
          <Route
            path="/"
            render={() => {
              if (Cookie.load("userinfo")) {
                return <Layout></Layout>;
              } else {
                return <Redirect to="/login"></Redirect>;
              }
            }}
          ></Route>
        </Switch>
      </HashRouter>
    );
  }
}
export default index;
